import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:zootix/models/zt_coin_goods.model.dart';
import 'package:zootix/screens/goods/zt_goods_controller.dart';
import 'package:zootix/screens/goods/zt_goods_item.dart';
import 'package:zootix/services/zt_service.dart';
import 'package:zootix/store/zt_auth.store.dart';
import 'package:zootix/util/zt_screen_adaper_util.dart';
import 'package:zootix/widgets/zt_my_coins.dart';

class ZtGoodsPopup extends StatelessWidget {
  final _controller = Get.put<ZtGoodsController>(ZtGoodsController());
  ZtGoodsPopup({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(
          vertical: ZtScreenAdaper.height(10),
          horizontal: ZtScreenAdaper.width(10)),
      decoration: const BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(20), topRight: Radius.circular(20))),
      child: Column(
        children: [
          Row(
            children: [
              const ZtMyCoinsWidget(),
              const Spacer(),
              IconButton(
                  onPressed: () {
                    Get.back();
                  },
                  icon: const Icon(Icons.close))
            ],
          ),
          Expanded(child: _buildGoodsList())
        ],
      ),
    );
  }

  Widget _buildGoodsList() {
    return Obx(() => SingleChildScrollView(
            child: Column(
          children: _controller.goodsList
              .map((element) => _buildGoodsItem(element))
              .toList(),
        )));
  }

  Widget _buildGoodsItem(ZtCoinGoodsModel item) {
    return ZtGoodsItem(goodsItem: item);
  }
}
